package com.dianping.cat.home.router.entity;

import com.dianping.cat.home.router.BaseEntity;
import com.dianping.cat.home.router.IVisitor;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;




public class RouterConfig
  extends BaseEntity<RouterConfig>
{
  private String m_backupServer;
  private int m_backupServerPort;
/*  17 */   private Map<String, DefaultServer> m_defaultServers = new LinkedHashMap();

/*  19 */   private Map<String, NetworkPolicy> m_networkPolicies = new LinkedHashMap();

/*  21 */   private Map<String, ServerGroup> m_serverGroups = new LinkedHashMap();

/*  23 */   private Map<String, Domain> m_domains = new LinkedHashMap();


  private Date m_startTime;


  private String m_domain;


  private Date m_endTime;


/*  35 */   public RouterConfig(String domain) { this.m_domain = domain; }




/*  40 */   public void accept(IVisitor visitor) { visitor.visitRouterConfig(this); }


  public RouterConfig addDefaultServer(DefaultServer defaultServer) {
/*  44 */     this.m_defaultServers.put(defaultServer.getId(), defaultServer);
/*  45 */     return this;
  }

  public RouterConfig addDomain(Domain domain) {
/*  49 */     this.m_domains.put(domain.getId(), domain);
/*  50 */     return this;
  }

  public RouterConfig addNetworkPolicy(NetworkPolicy networkPolicy) {
/*  54 */     this.m_networkPolicies.put(networkPolicy.getId(), networkPolicy);
/*  55 */     return this;
  }

  public RouterConfig addServerGroup(ServerGroup serverGroup) {
/*  59 */     this.m_serverGroups.put(serverGroup.getId(), serverGroup);
/*  60 */     return this;
  }


  public boolean equals(Object obj) {
/*  65 */     if (obj instanceof RouterConfig) {
/*  66 */       RouterConfig _o = (RouterConfig)obj;

/*  68 */       if (!equals(getDomain(), _o.getDomain())) {
/*  69 */         return false;
      }

/*  72 */       return true;
    }

/*  75 */     return false;
  }


/*  79 */   public DefaultServer findDefaultServer(String id) { return (DefaultServer)this.m_defaultServers.get(id); }



/*  83 */   public Domain findDomain(String id) { return (Domain)this.m_domains.get(id); }



/*  87 */   public NetworkPolicy findNetworkPolicy(String id) { return (NetworkPolicy)this.m_networkPolicies.get(id); }



/*  91 */   public ServerGroup findServerGroup(String id) { return (ServerGroup)this.m_serverGroups.get(id); }


  public Domain findOrCreateDomain(String id) {
    Domain domain = (Domain)this.m_domains.get(id);

/*  97 */     if (domain == null) {
/*  98 */       synchronized (this.m_domains) {
/*  99 */         domain = (Domain)this.m_domains.get(id);

/* 101 */         if (domain == null) {
/* 102 */           domain = new Domain(id);
/* 103 */           this.m_domains.put(id, domain);
        }
      }
    }

/* 108 */     return domain;
  }

  public NetworkPolicy findOrCreateNetworkPolicy(String id) {
/* 112 */     NetworkPolicy networkPolicy = (NetworkPolicy)this.m_networkPolicies.get(id);

/* 114 */     if (networkPolicy == null) {
/* 115 */       synchronized (this.m_networkPolicies) {
/* 116 */         networkPolicy = (NetworkPolicy)this.m_networkPolicies.get(id);

/* 118 */         if (networkPolicy == null) {
/* 119 */           networkPolicy = new NetworkPolicy(id);
/* 120 */           this.m_networkPolicies.put(id, networkPolicy);
        }
      }
    }

/* 125 */     return networkPolicy;
  }

  public ServerGroup findOrCreateServerGroup(String id) {
/* 129 */     ServerGroup serverGroup = (ServerGroup)this.m_serverGroups.get(id);

/* 131 */     if (serverGroup == null) {
/* 132 */       synchronized (this.m_serverGroups) {
/* 133 */         serverGroup = (ServerGroup)this.m_serverGroups.get(id);

/* 135 */         if (serverGroup == null) {
/* 136 */           serverGroup = new ServerGroup(id);
/* 137 */           this.m_serverGroups.put(id, serverGroup);
        }
      }
    }

/* 142 */     return serverGroup;
  }


/* 146 */   public String getBackupServer() { return this.m_backupServer; }



/* 150 */   public int getBackupServerPort() { return this.m_backupServerPort; }



/* 154 */   public Map<String, DefaultServer> getDefaultServers() { return this.m_defaultServers; }



/* 158 */   public String getDomain() { return this.m_domain; }



/* 162 */   public Map<String, Domain> getDomains() { return this.m_domains; }



/* 166 */   public Date getEndTime() { return this.m_endTime; }



/* 170 */   public Map<String, NetworkPolicy> getNetworkPolicies() { return this.m_networkPolicies; }



/* 174 */   public Map<String, ServerGroup> getServerGroups() { return this.m_serverGroups; }



/* 178 */   public Date getStartTime() { return this.m_startTime; }



  public int hashCode() {
/* 183 */     int hash = 0;

/* 185 */     return hash * 31 + ((this.m_domain == null) ? 0 : this.m_domain.hashCode());
  }




  public void mergeAttributes(RouterConfig other) {
/* 192 */     assertAttributeEquals(other, "router-config", "domain", this.m_domain, other.getDomain());

/* 194 */     if (other.getBackupServer() != null) {
/* 195 */       this.m_backupServer = other.getBackupServer();
    }

/* 198 */     this.m_backupServerPort = other.getBackupServerPort();

/* 200 */     if (other.getStartTime() != null) {
/* 201 */       this.m_startTime = other.getStartTime();
    }

/* 204 */     if (other.getEndTime() != null) {
/* 205 */       this.m_endTime = other.getEndTime();
    }
  }


/* 210 */   public DefaultServer removeDefaultServer(String id) { return (DefaultServer)this.m_defaultServers.remove(id); }



/* 214 */   public Domain removeDomain(String id) { return (Domain)this.m_domains.remove(id); }



/* 218 */   public NetworkPolicy removeNetworkPolicy(String id) { return (NetworkPolicy)this.m_networkPolicies.remove(id); }



/* 222 */   public ServerGroup removeServerGroup(String id) { return (ServerGroup)this.m_serverGroups.remove(id); }


  public RouterConfig setBackupServer(String backupServer) {
/* 226 */     this.m_backupServer = backupServer;
/* 227 */     return this;
  }

  public RouterConfig setBackupServerPort(int backupServerPort) {
/* 231 */     this.m_backupServerPort = backupServerPort;
/* 232 */     return this;
  }

  public RouterConfig setDomain(String domain) {
/* 236 */     this.m_domain = domain;
/* 237 */     return this;
  }

  public RouterConfig setEndTime(Date endTime) {
/* 241 */     this.m_endTime = endTime;
/* 242 */     return this;
  }

  public RouterConfig setStartTime(Date startTime) {
/* 246 */     this.m_startTime = startTime;
/* 247 */     return this;
  }

  public RouterConfig() {}
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/classes/!/com/dianping/cat/home/router/entity/RouterConfig.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */